﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CloudFranceTriple.Models;

namespace CloudFranceTriple.WebRole.Areas.Gaming.Controllers
{
    [CloudFranceTriple.WebRole.Filters.InitializeSimpleMembership]
    public class LaBaffGuildmasterController : Controller
    {
        private cloudfrAboq2RsDMEntities db = new cloudfrAboq2RsDMEntities();

        //
        // GET: /Gaming/LaBaffGuildmaster/

        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Index()
        {
            var labaffguildmasterset = db.LaBaffGuildMasterSet.Include(l => l.LaBaffSet);
            return View(labaffguildmasterset.ToList());
        }

        //
        // GET: /Gaming/LaBaffGuildmaster/Details/5

        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Details(int id = 0)
        {
            LaBaffGuildMasterSet labaffguildmasterset = db.LaBaffGuildMasterSet.Find(id);
            if (labaffguildmasterset == null)
            {
                return HttpNotFound();
            }
            return View(labaffguildmasterset);
        }

        //
        // GET: /Gaming/LaBaffGuildmaster/Create

        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Create()
        {
            ViewBag.TeamId = new SelectList(db.LaBaffSet, "Id", "LaBaffWebsite");
            return View();
        }

        //
        // POST: /Gaming/LaBaffGuildmaster/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Create(LaBaffGuildMasterSet labaffguildmasterset)
        {
            if (ModelState.IsValid)
            {
                db.LaBaffGuildMasterSet.Add(labaffguildmasterset);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.TeamId = new SelectList(db.LaBaffSet, "Id", "LaBaffWebsite", labaffguildmasterset.TeamId);
            return View(labaffguildmasterset);
        }

        //
        // GET: /Gaming/LaBaffGuildmaster/Edit/5

        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Edit(int id = 0)
        {
            LaBaffGuildMasterSet labaffguildmasterset = db.LaBaffGuildMasterSet.Find(id);
            if (labaffguildmasterset == null)
            {
                return HttpNotFound();
            }
            ViewBag.TeamId = new SelectList(db.LaBaffSet, "Id", "LaBaffWebsite", labaffguildmasterset.TeamId);
            return View(labaffguildmasterset);
        }

        //
        // POST: /Gaming/LaBaffGuildmaster/Edit/5

        [HttpPost]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Edit(LaBaffGuildMasterSet labaffguildmasterset)
        {
            if (ModelState.IsValid)
            {
                db.Entry(labaffguildmasterset).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.TeamId = new SelectList(db.LaBaffSet, "Id", "LaBaffWebsite", labaffguildmasterset.TeamId);
            return View(labaffguildmasterset);
        }

        //
        // GET: /Gaming/LaBaffGuildmaster/Delete/5

        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult Delete(int id = 0)
        {
            LaBaffGuildMasterSet labaffguildmasterset = db.LaBaffGuildMasterSet.Find(id);
            if (labaffguildmasterset == null)
            {
                return HttpNotFound();
            }
            return View(labaffguildmasterset);
        }

        //
        // POST: /Gaming/LaBaffGuildmaster/Delete/5

        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        [Authorize(Roles = "RoleAdminLaBaff")]
        public ActionResult DeleteConfirmed(int id)
        {
            LaBaffGuildMasterSet labaffguildmasterset = db.LaBaffGuildMasterSet.Find(id);
            db.LaBaffGuildMasterSet.Remove(labaffguildmasterset);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}